const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  //   entry: ['./src/index.js', './src/add.js'],//打包成单个js,适用于比如react全家桶
  entry: { index: './src/js/index.js', add: './src/js/add.js' }, // 打包成多个js
  output: {
    filename: '[name].js',
    path: `${__dirname}/build`,
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
    ],
  },
  plugins: [new HtmlWebpackPlugin()],
  mode: 'development',
  // resolve 解析模块的规则
  resolve: {
    // 配置解析模块路径名称
    alias: {
      $css: `${(__dirname, '/src/css')}`,
    },
    // 配置省略后缀名
    extensions: ['.js', '.json', '.css', 'jsx'],
    // 解析模块的目录
    modules: [`${__dirname}/../../node_modules`, 'node_modules'],
  },
};
